<template>
	<view>
		<!-- 1，头部组件 -->
		<detail-head :title="reqObject.text"></detail-head>
		<!-- 2，详情组件 -->
		<view class="list" v-for="(item,index) in detailList" :key="index">
			<detail-item :contentData="item"></detail-item>
		</view>
		<!-- 3，没有数据 -->
		<view class="null-list" v-if="detailList.length == 0">
			<text>没有更多数据。。。</text>
		</view>
	</view>
</template>

<script>
	//导入子组件
	import detailHead from './child/detail-head.vue'
	import detailItem from './child/detail-item.vue'

	import {
		queryByTypePage
	} from '@/api/http/main/release/dynamic.js'


	export default {
		components: {
			detailHead,
			detailItem
		},
		data() {
			return {
				reqObject: {},
				detailList: [],
				page: 1,
				size: 10,
				userId: uni.getStorageSync('userId')
			}
		},
		methods: {
			//1，获取数据
			getDetailList(typeId) {
				
				var userId = uni.getStorageSync('userId');
				var req = {}
				if (!userId || userId == '') {
					req = {
						page: this.page,
						size: this.size,
						typeId: typeId,
						state: '1',
						isReleaseUser: 3
					}
				} else {
					req = {
						page: this.page,
						size: this.size,
						typeId: typeId,
						state: '1',
						isReleaseUser: 1,
						userId,
					}
				}
				
				queryByTypePage(req).then(res => {
					if (res.data.pubInfo.code !== 0) {
						return uni.$showMsg(res.data.pubInfo.message);
					}
					//console.log(res.data.busInfo)
					this.detailList = res.data.busInfo
				})
			}
		},
		onLoad(e) {
			var req = JSON.parse(e.reqObject)
			this.reqObject = req
			this.reqObject.typeId = req.id

			this.getDetailList(req.id)
		},
		// onPullDownRefresh() {
		// 	console.log('rqwerwe')
		// },
		onReachBottom() {
			this.page = this.page + 1
			this.getDetailList(this.reqObject.typeId)
			//console.log('rqwerwe')
		}
	}
</script>

<style lang="scss" scoped>
	.null-list {
		height: 160rpx;
		line-height: 160rpx;
		text-align: center;
		font-size: 32rpx;
		color: rgba(128, 128, 128, 1);
	}
</style>